﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnATous
{
    public partial class MyGrade : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<string> grades = new List<string>() { "pestiféré", "haï", "détesté", "mal-aimé", "banal", "apprécié", "adoré", "aimé", "Dieu" };
            BusinessManagement.Facebook facebook = new BusinessManagement.Facebook();
            BusinessManagement.Rating ratingBM = new BusinessManagement.Rating();
            BusinessManagement.Feature featureBM = new BusinessManagement.Feature();

            DBO.User user = facebook.GetUser();

            float moy = ratingBM.GetMoyenne(user);
            UserGrade.Text = moy.ToString(); // La note de l'utilisateur, entre 0 et 5 (ou 1 et 5, ou 0 et 4, enfin ce que tu as mis.

            GradeMeaning.Text = grades[((int)moy) * 2]; // Choisissez des termes en fonction de la note (haï, commun, aimé, adoré, détesté…). De 0,5 et 0,5, par exemple.
            
            List<int> gradePerFeature = ratingBM.GetListCountFeature(user);
            List<DBO.Feature> features = featureBM.GetFeatureList();
            List<DBO.TmpCaract> list = new List<DBO.TmpCaract>();
            foreach (DBO.Feature feature in features)
                list.Add(new DBO.TmpCaract(feature.Name, "../" + feature.Icon, gradePerFeature[(int)feature.Id - 1].ToString()));
            
            CaractList.DataSource = list;
            CaractList.DataBind();
        }
    }
}